﻿// JavaScript Document
$(function(){
  var i = 5;  //已知显示的<a>元素的个数
  var m = 5;  //用于计算的变量
  var $content = $("#list_img");
  var count = $content.find("img").length;
  $("#rool_list img").eq(0).css({"border":"2px solid  #A1D215","opacity":"0.5","cursor":"pointer"});
  $("#nextlabel").live("click",function(){
		var $scrollableDiv = $(this).siblings("#list_img").find("#rool_list");
		if( !$scrollableDiv.is(":animated")){  
			if(m<count){  
				m++;
				$scrollableDiv.animate({left: "-=58px"}, 600);
			}
			else
			{
				$("#nextlabel").attr({title: "已经最后一张了"}); 
				$("#nextlabel").css({"opacity":"0.5"});
				$("#prevlabel").css({"opacity":"1.0"});  
			}				
		}
		return false;
  });
   //上一张
  $("#prevlabel").live("click",function(){
		var $scrollableDiv = $(this).siblings("#list_img").find("#rool_list");
		if( !$scrollableDiv.is(":animated")){
			if(m>i){ 
				m--;
				$scrollableDiv.animate({left: "+=58px"}, 600);
			}
			else
			{
				$("#prevlabel").attr({title: "已经是第一张了"}); 
				$("#prevlabel").css({"opacity":"0.5"});
				$("#nextlabel").css({"opacity":"1.0"});   
			}
		}
		return false;
});	  


$("#rool_list img").hover(function(){
	$(this).css({"border":"2px solid  #A1D215","opacity":"0.5","cursor":"pointer"}).siblings().css({"border":"1px solid  #bbb","opacity":"1.0"});
	this.myTitle = this.alt;
	this.title = "";
	$("#showImg").html('<img src="'+ this.myTitle +'">');            
	}).mouseout(function(){
		this.myTitle = this.alt;	
	}).mousemove(function(){
});

})
 
